package service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import service.UserService;
import dao.UserDao;
import entity.User;

import javax.annotation.Resource;
import javax.annotation.Resources;

/**
 * 用户业务类，实现对User功能的业务管理
 */
@Service("userService")
public class UserServiceImpl implements UserService {

	// 声明接口类型的引用，和具体实现类解耦合
	@Resource
	private UserDao dao;
	private String i1;
	private String i2;
	private int i3;

	public UserServiceImpl() {
	}

	public UserServiceImpl(UserDao dao, String i1){
		this.dao=dao;
		this.i1=i1;
	}
	public UserServiceImpl(String i2,UserDao dao){
		this.dao=dao;
		this.i2=i2;
	}
	public UserServiceImpl(UserDao dao,int i3){
		this.dao=dao;
		this.i3=i3;
	}


	// dao 属性的setter访问器，会被Spring调用，实现设值注入
	public void setDao(UserDao dao) {
		this.dao = dao;
	}

	@Override
    public Object addNewUser(User user) {
		// 调用用户DAO的方法保存用户信息
		dao.save(user);
		System.out.println(i1);
		System.out.println(i2);
		System.out.println(i3);
//		throw new RuntimeException("测试时发生异常");
		return "4444444444";
	}
	@Override
	public Object addNewUser2(User user) {
		// 调用用户DAO的方法保存用户信息
		dao.save(user);
		return "4444444444";
	}
}